from enum import IntEnum
from typing import List

from pydantic import BaseModel, Field


class OptionSchema(BaseModel):
    """单项选择题选项结果"""
    option: str = Field(description="选项内容", default="")


class ChoiceOptionSchema(BaseModel):
    """多项选择题结果"""
    lists: List[OptionSchema] = Field(description="选项列表", default=[])


class MatchTpEnum(IntEnum):
    normal = 1
    radio = 2
    choice = 3


MatchTpEnum.normal.label = "文字匹配"
MatchTpEnum.radio.label = "单项选择"
MatchTpEnum.choice.label = "多项选择"


class AttributeMatchSchema(BaseModel):
    """【匹配设备属性】属性匹配接口参数-关键属性匹配类型"""
    keyword: str = Field(description="设备关键属性")
    tp: MatchTpEnum = Field(description="匹配类型", default=MatchTpEnum.normal.value)
    options: List[str] = Field(description="选项列表(单选或多选时有效)", default=[])
    math_text: str = Field(description="匹配文字结果", default="")
    match_list: List[str] = Field(description="匹配选项列表", default=[])


class MeterMatchSchema(BaseModel):
    """【匹配设备属性】属性匹配接口请求参数"""
    meter: str = Field(description="设备属性")
    attributes: List[AttributeMatchSchema] = Field(description="关键属性列表")


class AISearchReq(BaseModel):
    """AI 搜索商品"""
    platform: str = Field(description="平台名称(avl:平台，hushan:湖山)", default="avl")
    keyword: str = Field(description="描述")
